package com.wnx.action;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.apache.struts2.ServletActionContext;

import com.opensymphony.xwork2.ActionSupport;
import com.wnx.db.CollectDao;
import com.wnx.entity.Collect;

public class CollectAction extends ActionSupport {
	private int gid;
	private int uid;
	private String type;
	
	public String getType() {
		return type;
	}
	public void setType(String type) {
		this.type = type;
	}
	public int getGid() {
		return gid;
	}
	public void setGid(int gid) {
		this.gid = gid;
	}
	public int getUid() {
		return uid;
	}
	public void setUid(int uid) {
		this.uid = uid;
	}
	public String execute() {
		
		if(this.type.equals("collect")){
			Collect c = new Collect();
			c.setUid(this.uid);
			c.setGid(this.gid);
			c.setState(1);
			CollectDao cd = new CollectDao();
			cd.saveG(c);
			return SUCCESS;
		}else if(this.type.equals("cancle")){
			Collect c = new Collect();
			c.setGid(this.gid);
			CollectDao cd = new CollectDao();
			cd.delCollectBygid(c);
			return SUCCESS;
		}
		else{
			return ERROR;
		}
		
	}
}
